<?php
/**
 * Created By base
 * Author: Virus
 * Date: 2020/3/11
 * Time: 13:54
 */

namespace app\admin\logic;


use think\facade\Log;

class BaseLogic
{
    /**
     * @param $where
     * @return array
     */
    public function getLists($where)
    {
        try {
            $lists = $this->model->getLists($where);
        } catch (\Exception $e) {
            // 记录日志
            Log::record($e->getMessage());

            // 返回空数组
            return [];
        }

        return $lists->toArray();
    }

    /**
     * @param $id
     * @return array
     */
    public function findOne($id)
    {
        try {
            $oneData = $this->model->findOne($id);
        } catch (\Exception $e) {
            Log::record($e->getMessage());

            return [];
        }

        return $oneData;
    }
}